import { defHttp } from '/@/utils/http/axios';
import { AddWorkItemProxy, SaveWorkItemParam } from './model/workItemProxyModel';

enum Api {
  GetProxyInfoExist = '/workflow/workItemProxy/getProxyInfoExist',
  AddProxyInfo = '/workflow/workItemProxy/addProxyInfo',
  EditProxyInfo = '/workflow/workItemProxy/editProxyInfo',
  TemplateList = '/workflow/workItemInst/template/list',
  SaveWorkItemRight = '/workflow/workItemRight/saveWorkItemRight',
}

// 校验数据是否重复
export const getProxyInfoExist = (params: AddWorkItemProxy) =>
  defHttp.post<any>({ url: Api.GetProxyInfoExist, params });

// 新增授权数据
export const AddProxyInfo = (params: AddWorkItemProxy) =>
  defHttp.post<any>({ url: Api.AddProxyInfo, params });

// 编辑数据
export const editProxyInfo = (params: AddWorkItemProxy) =>
  defHttp.post<any>({ url: Api.EditProxyInfo, params });

// 流程列表模板 TemplateList
export const getTemplateList = () =>
  defHttp.post<any>({
    url: Api.TemplateList,
    params: {
      validFlag: 1,
    },
  });
// 保存/新建模板权限分配 SaveWorkItemRight
export const saveWorkItemRight = (params: SaveWorkItemParam) =>
  defHttp.post<any>({
    url: Api.SaveWorkItemRight,
    params,
  });
